<?php
    $coll_id = 0;
    
    if(isset($_GET["id"])) $coll_id = (int)$_GET["id"];
    if(isset($_POST["id"])) $coll_id = (int)$_POST["id"];

    require_once(dirname(__FILE__)."/lib/Loader.php");
    $dbh = dbh();
?>
<html>
<head>
<style>
    input { font: normal 12px Arial, Helvetica, sans-serif;padding:0; margin:0; line-height:1.8em;color: #333333; text-decoration: none; }
    input[type=text] { width:800px; border-radius:2px; -moz-border-radius:2px; -webkit-border-radius:4px; box-shadow:0 1px 2px #ddd; -moz-box-shadow:0 1px 2px #ddd; -webkit-box-shadow:0 1px 2px #ddd; border:
1px solid #aaa; color:#555555; padding:1px; margin:1px; }
    textarea { font: normal 12px Arial, Helvetica, sans-serif;padding:0; margin:0; line-height:1.8em;color: #333333; text-decoration: none;
                       width:800px; height:100px; }
</style>
</head>

<body>
<?php
    cload("addData.addDataCollRow");
    
    $row = new addDataCollRow($dbh, $coll_id);
    $row->load();
    
    $action = "";
    if(isset($_POST["action"])) $action = $_POST["action"];
    if(isset($_GET["action"])) $action = $_GET["action"];
    
    if($action=="send") {
        $post = $_POST;
        unset($post["action"]);
        $row->setElements($post);
        
//        _print_r($row->getElements());
        $row->save();
        echo 'Обновлено. <a href="admDopData.php">К списку наборов</a>';
        exit();
    }
?>
    <h3>Создание/редактирование набора данных</h3>
    
    <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
        <input type="hidden" name="id" value="<?php echo $row->get("id"); ?>" />
        <input type="hidden" name="action" value="send" />
        <table border="0">
            <tr><td>Имя набора</td><td>     <input type="text" name="name" value="<?php echo htmlspecialchars($row->get("name")); ?>" /></td></tr>
            <tr><td>Описание набора</td><td><input type="text" name="title" value="<?php echo htmlspecialchars($row->get("title")); ?>" /></td></tr>
            <tr><td colspan="2"><input type="submit" /><td></tr>
        </table>
    </form>
</body>
</html>